package puzzle.common.loader;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

public class BuiltinProblemDictionary extends AbstractProblemDictionary {
	private String[] m_names;
	private String m_suffix;

	public BuiltinProblemDictionary(String[] names, String suffix) {
		m_names = names;
		m_suffix = suffix;
	}

	@Override
	public Reader getProblemData(String name) throws IOException {
		return new InputStreamReader(getClass().getResourceAsStream(name + m_suffix));
	}
	
	@Override
	public String[] getProblemNames() {
		return m_names;
	}

	public static String[] createIndexedNames(String format, int start, int end) {
		String[] names = new String[end - start + 1];
		for (int i = start; i <= end; i++) {
			names[i - start] = String.format(format, i);
		}
		return names;
	}
}
